package com.csw01;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class selectMysql01 {
    public static void main(String[] args) throws Exception{
        Class.forName("com.mysql.jdbc.Driver");
        String url="jdbc:mysql://master:3306/csw";
        String username="root";
        String password="123456";
        Connection connection = DriverManager.getConnection(url, username, password);
        Statement statement = connection.createStatement();
        String sid="1004 or 1=1";
        String sql="select * from student where sid="+sid;
        System.out.println(sql);
        ResultSet rs = statement.executeQuery(sql);
        while (rs.next()){
            String name = rs.getString("name");
            int age = rs.getInt("age");
            String sex = rs.getString("sex");
            System.out.println(name+"---"+age+"---"+sex);
        }
        rs.close();
        statement.close();
        connection.close();
    }
}
